<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\HoardingInstruction;

class HoardingInstructionController extends Controller
{
    public function __construct()
    {
        view()->share([
            '_ts' => 'am-in',
            '_listInstruction' => 'am-active',
        ]);

    }

    //囤票说明
    public function listInstruction(Request $request){
        $InstructionArr=HoardingInstruction::get();
        return view('admin.hoardinginstruction.listInstruction',compact('InstructionArr'));
    }

    //新增囤票说明
    public function addInstruction(){
        return view('admin.hoardinginstruction.addInstruction');
    }


    //保存或新增囤票信息说明
    public function addOrUpdateInstruction(Request $request){
        HoardingInstruction::addOrUpdate($request->id,$request->title,$request->description,$request->start_end_time);
        return redirect('admin/listInstruction')->with('success', '操作成功');

    }

    //修改充值面额
    public function updateInstruction($id){
        $instructionInfo=HoardingInstruction::store($id);
        return view('admin.hoardinginstruction.updateInstruction',compact('instructionInfo'));
    }


    //删除充值面额
    public function deleteInstruction($id){
        $status=HoardingInstruction::destroy($id);
        if($status){
            return redirect('admin/listInstruction')->with('success','删除成功');
        }

    }
}
